package main

import (
	"context"
	"k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/tools/clientcmd"
)

func kubernetesClient() (*kubernetes.Clientset, error) {
	kubeConfig := clientcmd.RecommendedHomeFile
	config, err := clientcmd.BuildConfigFromFlags("", kubeConfig)
	if err != nil {
		panic(err.Error())
	}

	return kubernetes.NewForConfig(config)
}

func kubernetesNodes(client *kubernetes.Clientset) (*v1.NodeList, error) {
	return client.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
}
